package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.List;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

import model.Review;

/**
 * This class displays the information contained in a review.
 * @author Gregory Coleman
 *
 */
public class RevRead extends JFrame {

	private int[] ratings;
	
	private List<String> reasons;
	
	private Review review;
	private JTabbedPane tabbedPane;
	
	public RevRead(Review rev) {
		super();
		review = rev;
		reasons = rev.getReasons();
		ratings = rev.getScores();
		setDefaultCloseOperation(this.DISPOSE_ON_CLOSE);
		tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);
		add(tabbedPane, BorderLayout.CENTER);
		init();
		pack();
		tabbedPane.setSelectedIndex(0);
	}
	
	private void init() {
		JPanel temp;
		String rate;
		JTextArea reason;
		for (int i = 0; i < ratings.length; i++) {
			temp = new JPanel();
			temp.setLayout(new BorderLayout());
			rate = "Rating: " + ratings[i];
			temp.add(new JLabel(rate),BorderLayout.NORTH);
			reason = new JTextArea(reasons.get(i));
			reason.setEditable(false);
			temp.add(reason, BorderLayout.CENTER);
			temp.setPreferredSize(new Dimension(600,400));
			tabbedPane.addTab(""+(i+1),null,temp,null);
		}
	}
}
